package com.tianqu.tms.www.financia.controller;

import java.util.List;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsController;
import com.tianqu.tms.core.base.TxController;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.exception.TransactionException;
import com.tianqu.tms.dto.TmsFinanciaDto;
import com.tianqu.tms.dto.TmsFinanciaParam;
import com.tianqu.tms.entity.TmsFinancial;

public class FinanciaCompanyDetailController  extends TmsController {
	public static final String DATA = "list";
	private Logger logger = Logger.getLogger(FinanciaCompanyDetailController.class);
	@Override
	public void execute(UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		TxController controller = TxController.getTxController();
		// 添加事务提交异常捕获
		try {
			controller.begin();
			TmsFinancial financial = TmsFinancial.getInstance();
			String id = (String)uc.getParameter("id");
			TmsFinanciaParam param = new TmsFinanciaParam();
			param.setId(id);
			List<TmsFinanciaDto> list = financial.findTmsFinancia(param);
			controller.commit();
			uc.setAttribute(DATA, list);
			logger.debug(this.getClass().getName() + "#execute was completed.");
		} catch (Exception e) {
			try {
				controller.rollback();
			} catch (TransactionException e1) {
				throw new TmsException(TmsException.DB_TXCRROR, e1);
			}
			// 系统异常
			if (e instanceof TmsException) {
				throw e;
			}
			throw new TmsException(TmsException.DB_TXCRROR, e);
		}

	}
}
